package com.mj.service.system;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.mj.dao.system.DeptMapper;
import com.mj.model.system.Dept;
import com.mj.util.CommonUtil;
@Service("deptService")
public class DeptServiceImpl implements DeptService {

	@Resource
	private DeptMapper deptDao;
	@Resource
    CommonUtil commonUtil;
	@Override
	public Dept selectByPrimaryKey(Integer deptId) {
		return deptDao.selectByPrimaryKey(deptId);
	}
	@Override
	public int updateByPrimaryKeySelective(Dept record) {
		return deptDao.updateByPrimaryKeySelective(record);
	}
	@Override
	public List<Dept> findAllDept(Map<String, Object> map) {
		return deptDao.findAllDept(map);
	}
	@Override
	public int countDept(Map<String, Object> map) {
		return deptDao.countDept(map);
	}
	@Override
	public List<Map<String, Object>> loadByDeptName(List<Dept> mlist,
			String name) {
		List<Map<String,Object>> maplist = null;
    	if(null != name && !name.equals("")){
    		maplist = new  ArrayList<Map<String,Object>>();  
    	    for (Dept m : mlist) {
 	    	   Map<String,Object> tn = new HashMap<String,Object>();
 	    	   tn.put("title", m.getDeptName());
 	    	   tn.put("id",m.getDeptId());
 	    	   tn.put("num", m.getDeptNum());
 	    	   tn.put("status", m.getStatus());
 	    	  maplist.add(tn);
 	       }
    	}else{
    		maplist = commonUtil.deptMapList(mlist, 0);
    	}
		return maplist;
	}
	@Override
	public int insertSelective(Dept record) {
		return deptDao.insertSelective(record);
	}
	
}
